file = io.open("test.txt","r");
print(file:read())
for line in io.lines("test.txt") do
    print(line)
end
file:seek("end",-3)
file:close()
-- 尽量不使用 .. 有额外消耗 比如io.write(a,b,c) 避免io.write(a..b..c)
io.write("hello world")
io.write(string.format("sin(3) = %.4f\n",math.sin(3)))
-- io.read "a" 读取整个文件 
-- "l"读取下一行(丢弃换行符)默认参数 "L" 读取下一行(保留换行符)
-- "n" 读取一个数值 num 以字符串读取num个字符
-- t = io.read("a")
-- t = string.gsub(t,"bad","good")
t = io.read("a")
t = string.gsub(t,"([\128-\255=])",function (c)
    return string.format("=%02X",string.byte(c))
end)
io.write(t)
for count = 1, math.huge do
    local line = io.read("L")
    if line == nil then break end
    io.write(string.format("%6d",count),line)
end
local lines = {}
for line in io.lines() do
    lines[#lines+1] = line
end
table.sort(lines)
for _,l in ipairs(lines) do
    io.write(l,"\n")
end
-- local x = io.read(2 ^ 13)
-- print(x)